import request from '@/utils/request'
import type { CategoryResponseData } from './type'

enum API {
    // 获取分类列表
    CATEGORY_LIST_URL = '/api/categories',
}

// 获取分类列表
export const reqCategoryList = (params: any) => 
    request.get<any, CategoryResponseData>(API.CATEGORY_LIST_URL, { params })

// 添加分类
export const reqAddCategory = (data: any) => 
    request.post<any, any>(API.CATEGORY_LIST_URL, data)

// 修改分类
export const reqUpdateCategory = (id: number, data: any) => 
    request.put<any, any>(`${API.CATEGORY_LIST_URL}/${id}`, data)

// 删除分类
export const reqDeleteCategory = (id: number) => 
    request.delete<any, any>(`${API.CATEGORY_LIST_URL}/${id}`) 